import csv
list01 = [["名称","数量"], ["苹果","18"], ["西瓜","10"]]
# newlines="" 解决windows下面每一行多加一个空行
with open("fruit.csv", "w", encoding="utf-8-sig") as f:
    writer = csv.writer(f)
    writer.writerows(list01)
